package com.libbase.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.libbase.R;

public class NavigationTabView extends LinearLayout {

    ImageView rb_navigation_tab;

    TextView tv_unread_navigation_tab;

    TextView tv_tab;

    private int selectImageId;
    private int unselectImageId;

    public NavigationTabView(Context context) {
        super(context);
        init(context);

    }

    public NavigationTabView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);

    }

    public NavigationTabView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    private void init(Context context) {
        inflate(context, R.layout.view_navigation_tab, this);
        tv_tab = findViewById(R.id.tv_tab);
        tv_unread_navigation_tab = findViewById(R.id.tv_unread_navigation_tab);
        rb_navigation_tab = findViewById(R.id.rb_navigation_tab);
    }

    public void setRadioButtonBG(int selectImageId, int unselectImageId, String name) {
        this.selectImageId = selectImageId;
        this.unselectImageId = unselectImageId;
        tv_tab.setText(name);
    }

    public void setCheck(boolean check) {
        rb_navigation_tab.setImageResource(check ? selectImageId : unselectImageId);
        tv_tab.setTextColor(check ? getResources().getColor(R.color.red) : getResources().getColor(R.color.text_20));
    }

    public void showRedPoint(boolean show) {
        tv_unread_navigation_tab.setVisibility(show ? VISIBLE : GONE);
    }
}
